package com.ssy.lingxi.dto.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 请款单明细单据类型枚举
 * @author 彭冬冬
 * @date 2021/12/19
 * @version 2.0.0
 */
public enum ApplyAmountRowBillTypeEnum {

    /**
     * 订单
     */
    ORDER(1, "订单"),
    /**
     * 合同
     */
    CONTRACT(2, "合同"),
    /**
     * 退货申请
     */
    RETURN_REQUEST(3, "收货退货"),

    ;

    /**
     * 值
     */
    private int code;

    /**
     * 标签
     */
    private String name;

    ApplyAmountRowBillTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getNameByCode(int code) {
        ApplyAmountRowBillTypeEnum billTypeEnum = Arrays.stream(ApplyAmountRowBillTypeEnum.values()).filter(f -> f.getCode() == code).findFirst().orElse(null);
        return billTypeEnum == null ? SettlementHelpEnum.UNKNOWN.getMessage() : billTypeEnum.getName();
    }
}
